package com.ywu.third.exec.standard.exec.param.iml;

import com.ywu.common.gson.GsonUtils;
import com.ywu.third.exec.standard.entity.YwuThirdExecParamEntity;
import com.ywu.third.exec.standard.exec.param.YwuExecParamParse;
import org.springframework.stereotype.Component;

/**
 * @ClassName YwuExecParamParseInt
 * @Description TODO
 * @Author GroundDemo
 * @Date 2024/10/16 9:04
 * @Version 1.0
 **/
@Component
public class YwuExecParamParseInt implements YwuExecParamParse {

    private static final String INTEGER_PARAM_TYPE = "int";

    /**
     * @Author GroundDemo
     * @Description 参数类型
     * @Date 9:04 2024/10/16
     * @Param []
     * @return java.lang.String
     **/
    @Override
    public String paramType() {
        return INTEGER_PARAM_TYPE;
    }

    /**
    * @Author GroundDemo
    * @Description 参数转换
    * @Date 9:05 2024/10/16
    * @Param [entity]
    * @return java.lang.Object
    **/
    @Override
    public Object parse(YwuThirdExecParamEntity entity) {
        if (entity.getIsArray()) {
            return GsonUtils.deserializeList(entity.getValue(), Integer.class);
        } else {
            String value = entity.getValue();
            return Integer.parseInt(value);
        }
    }
}
